<?php
/**
 * Ini file writer class.
 * 
 * @package EICms
 * @subpackage library
 * @author hcderaad
 */
/**
 * Ini file writer class.
 * 
 * @package EICms
 * @subpackage library
 * @author hcderaad
 */
class EICms_IniWriter {
	
	/**
	 * Writes the given inivalues (array) to a file.
	 *
	 * @param array $iniValues
	 * @param string $fileName
	 * @param boolean $hasSection Default True.
	 * @return boolean
	 */
	public static function write($iniValues,$fileName,$hasSections = true) {
		$iniContents = '';
		if($hasSections) {
			foreach($iniValues as $section => $values) {
				$iniContents .= '[' . $section . ']' . PHP_EOL;
				foreach($values as $key => $value) {
					$iniContents .= $key . ' = ' . $value . PHP_EOL;
				}
				$iniContents .= PHP_EOL;
			}
		}
		else {
			foreach($iniValues as $key => $value) {
				$iniContents .= $key . ' = ' . $value . PHP_EOL;
			}
		}
		return file_put_contents($fileName,$iniContents);
	}
}
?>